import React from 'react';
import { connect, history } from 'umi';
import {AdminModelState} from '../pages/login/model'
import {Button} from 'antd'

const Header = (props: AdminModelState) => {
  return (
    <div>
      {
      props.adminname
      ?
      (<p>欢迎 {props.adminname} <Button onClick={()=>{
        localStorage.clear()
        history.push('/login')
      }}>退出</Button></p>)
      :
      (<p><Button onClick={()=>{
        history.push('/login')
      }}>未登录/去登录</Button></p>)
      }
    </div>
  );
};

export default connect(({admin}: {admin: AdminModelState})=>{
  return {
    adminname: admin.adminname
  }
})(Header);
